package leetcode_top;

import java.util.*;

// 最大整数
public class Ex179 {
    class Solution {
        public String largestNumber(int[] nums) {
            Queue<String> queue = new PriorityQueue<>((s2, s1) -> (s1 + s2).compareTo(s2 + s1));
            for (int i = 0; i < nums.length; i++) {
                queue.offer("" + nums[i]);
            }
            StringBuilder sb = new StringBuilder();
            while (!queue.isEmpty()) {
                sb.append(queue.poll());
            }
            String s = sb.toString();
            if (s.startsWith("0")) return "0";
            return s;
        }
    }
}
